/**
 * @projectName study_java
 * @package Memento
 * @className Memento.Test
 */
package Memento;

/**
 * Test
 * @description 测试类
 * @author answer_wx
 * @date 2022/6/29 18:22
 * @version 1.0
 */
public class Test {
    public static void main(String[] args) {
        /**
         * 创建一个游戏角色
         */
        UserRole userRole = new UserRole();
        /**
         * 初始化角色
         */
        userRole.initRole();
        System.out.println("角色初始状态");
        System.out.println(userRole.toString());
        System.out.println("开始备份");
        UserRoleManager userRoleManager = new UserRoleManager();
        userRoleManager.setUserRoleMemento(userRole.createMemento());
        System.out.println("角色开始战斗");
        userRole.fight();
        System.out.println(userRole.toString());
        userRole.fight();
        System.out.println(userRole.toString());
        userRole.fight();
        System.out.println(userRole.toString());
        System.out.println("开始恢复角色数据");
        userRole.recovery(userRoleManager.getUserRoleMemento());
        System.out.println(userRole.toString());
    }
}